/**
 * @description 处理客户端的具体请求
 * @author xfj
 */

import React from 'react';
import routes from '../share/route';
import app from './http';
import createServerStore from './store';
import render from './render';


app.get('*', async(req, res) => {
  const store = createServerStore();
  const routeInfo = routes.find(item => item.path.startsWith(req.path));
  if(routeInfo?.getData) {
    await routeInfo?.getData(store);
  }
  res.send(render(req, store));
});
